<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page language="java" import="java.util.*" %>
<%@  page import   =   "java.text.*"   %>
<%@  page import   =   "java.sql.*"   %>
<% String context = request.getContextPath();%>
<html>
<head>
<title>上传文件</title>
<link href="<%= request.getContextPath()%>/css/montview.css" rel="stylesheet" type="text/css"/>
<LINK href="<%=request.getContextPath()%>/css/oa.css" rel=stylesheet />
<LINK href="<%=request.getContextPath()%>/css/common.css" rel=stylesheet />
<script src="<%=request.getContextPath()%>/js/calender.js" language="javascript"></script>
<script src="<%=request.getContextPath()%>/js/check_char.js" language="javascript"></script>
<script language="javascript" src="<%= request.getContextPath()%>/js/calender.js" type=""></script>
<script src="<%=request.getContextPath()%>/js/ajax.js" language="javascript"></script>
<script src="<%=request.getContextPath()%>/js/mootools-1.2.1-core-yc.js" language="javascript"></script>
<Style>
.win {background-color: #C0D0E8;width:260px;font-family: verdana;font-size: 9pt;}
.Calendar {font-family: verdana;text-decoration: none;font-size: 9pt;border:0px dotted #1C6FA5 center;empty-cells:show;}
.CalendarTD {font-family: verdana;font-size: 8pt;color: #000000;background- color:white;height: 20px;text-align: left;empty-cells:show ;}
.CalendarTD1 {font-family: verdana;font-size: 8pt;color: #FF0000;background- color:white;height: 20px;text-align: left;empty-cells:show ;} 
</Style>
<script type="text/javascript" src="<%= request.getContextPath()%>/js/jquery-1.3.2.min.js"></script>

<script type="text/javascript">
var judeg=true;
function entry_excel(){
    var theFile = document.getElementById("theFile");
    if(theFile.value!=""){
        alert(theFile.value);
        var form=document.forms[0];   
        form.method='post';  
        form.setAttribute('encoding','multipart/form-data');  
        form.action='<%= request.getContextPath()%>/action1.do?action=getfile';  
        form.submit();
        }
     else {
         alert("请导入文件！");  
         return false; 
     }
}

function check(){
   var a=document.getElementById("path").value;
   var b=document.getElementById("path1").value;
   if(a.indexOf("DSBC_CASE")==-1){
                alert("导入文件错误"); 
                judeg=false;
                return false; 
   }
   if(b.indexOf("DSBC_CASE")==-1){
                alert("导入文件错误"); 
                judeg=false; 
                return false; 
   }
   if(a==b){
         alert("导入文件相同"); 
         judeg=false; 
         return false; 
   }
       a=a.substring((a.lastIndexOf("-")+1),a.length)
       var c=a.substring((a.indexOf("_")+1),(a.length-4));
       if(b.indexOf(c)==-1){
                alert("导入文件错误");
                judeg=false;  
                return false; 
       }
       document.getElementById("file_index").value=c.substring(0,c.indexOf("_"));
       document.getElementById("uploadfile").style.display="none";
       document.getElementById("wait").style.display="block";
}

function ajax(){
  check();
  if(judeg==false){
    return false;
  }
  document.getElementById("uploadfile").style.display="none";
  document.getElementById("wait").style.display="block";
  var url="<%= request.getContextPath()%>/action1.do?action=getfile";
  var myAjax = new Ajax1(url,{method:'POST',onComplete:function(){
  var data = JSON.decode(this.req.responseText);
  if(data=="OK"){
       document.getElementById("uploadfile").style.display="block";
       document.getElementById("wait").style.display="none";
  }
}})
}

</script>
</head>

<body>
<br><br><br>
<form  action="<%= request.getContextPath()%>/action1.do?action=getfile" method="POST" enctype="multipart/form-data" onsubmit="return check()">


<div align="center" id="uploadfile" style="display:block">
<div id=formTable>
<input type="hidden" id="file_index" name="file_index"/>
<table>

<tr>
<th height="24" class="yd_ltd" ><div align="right">上传文件：</div></th>
<td class="yd_ltd" >
           <input type="file" id="theFile" name="theFile" size=100 onchange="document.getElementById('path').value=encodeURI(this.value)">
          
           <input type="hidden" id="path" name="path"/>
</td>
</tr>
<tr>
<tr>
<th height="24" class="yd_ltd" ><div align="right">上传文件：</div></th>
<td class="yd_ltd" >
           <input type="file" id="theFile1" name="theFile1" size=100 onchange="document.getElementById('path1').value=encodeURI(this.value)">
           <input type="submit" name="submit"  id="submit" value="上传" >
           <input type="hidden" id="path1" name="path1"/>
</td>
</tr>
<tr>
</table>
</div>
</div>

<div align="center" id="wait" style="display:none">
   <table border="1" width="37%" cellspacing="0" cellpadding="4" style="border-collapse: collapse" bgcolor="#FFFFEC" height="87">
    <tr>
     <td bgcolor="#3399FF" style="font-size:12px;color:#ffffff" height=24>文件上传中...</td>
    </tr>
    <tr>
     <td style="font-size:12px;line-height:200%" align=center>文件正在上传处理中.请耐心等待...
     <marquee style="border:1px solid #000000" direction="right" width="300" scrollamount="5" scrolldelay="10" bgcolor="#ECF2FF">
     <table cellspacing="1" cellpadding="0">
     <tr height=8>
     <td bgcolor=#3399FF width=8></td>
     <td></td>
     <td bgcolor=#3399FF width=8></td>
     <td></td>
     <td bgcolor=#3399FF width=8></td>
     <td></td>
     <td bgcolor=#3399FF width=8></td>
     <td></td>
     </tr></table></marquee></td>
    </tr>
   </table>
</div>
</form>
</body>

</html>